<?php

/**
 * BolaoUser form.
 *
 * @package    bolao-aabb
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfPropelFormTemplate.php 10377 2008-07-21 07:10:32Z dwhittle $
 */
class BolaoAdminUserForm extends sfGuardUserAdminForm
{
  protected
    $pkName = null;

  public function configure()
  {
    parent::configure();

    unset(
      $this['last_login'],
      $this['created_at'],
      $this['salt'],
      $this['algorithm'],
      $this['sf_guard_user_group_list'],
      $this['sf_guard_user_permission_list']
    );

    $this->widgetSchema['username']->setLabel('Usu&aacute;rio');
    $this->widgetSchema['username']->setAttribute('class', 'small');

    $this->widgetSchema['password']->setLabel('Senha');
    $this->widgetSchema['password']->setAttribute('class', 'small');

    $this->widgetSchema['password_again']->setLabel('Confirme a senha');
    $this->widgetSchema['password_again']->setAttribute('class', 'small');

    $this->widgetSchema['first_name']->setLabel('Primeiro nome');
    $this->widgetSchema['first_name']->setAttribute('class', 'small');

    $this->widgetSchema['last_name']->setLabel('Sobrenome');
    $this->widgetSchema['last_name']->setAttribute('class', 'small');

    $years = array();
    for($i=1920; $i<2000; $i++) $years[$i] = $i;
    $this->widgetSchema['birthday'] = new sfWidgetFormDate(array(
      'label' => 'Anivers&aacute;rio',
      'format' => '%day%/%month%/%year%',
      'years' => $years
    ));

    $this->widgetSchema['email']->setLabel('E-mail');
    $this->widgetSchema['email']->setAttribute('class', 'medium');
    $this->validatorSchema['email'] = new sfValidatorAnd(array(
      $this->validatorSchema['email'],
      new sfValidatorEmail(array(), array('invalid' => 'Endere&ccedil;o inv&aacute;lido.'))
    ));

    $this->widgetSchema['home_phone']->setLabel('Tel. resid&ecirc;ncia');
    $this->widgetSchema['home_phone']->setAttribute('class', 'small');
    $this->validatorSchema['home_phone']->setMessage('max_length', 'Formato: "(XX) XXXX-XXXX"');

    $this->widgetSchema['cel_phone']->setLabel('Tel. celular');
    $this->widgetSchema['cel_phone']->setAttribute('class', 'small');
    $this->validatorSchema['cel_phone']->setMessage('max_length', 'Formato: "(XX) XXXX-XXXX"');

    $this->widgetSchema['is_active']->setLabel('Ativo?');

    $this->widgetSchema['is_super_admin']->setLabel('Administrador?');

    $postValidators = $this->getValidatorSchema()->getPostValidator()->getValidators();
    foreach ($postValidators as $validator)
    {
      if ($validator instanceof sfValidatorPropelUnique)
         $validator->setMessage('invalid', 'Este login já existe.');
      if ($validator instanceof sfValidatorSchemaCompare)
         $validator->setMessage('invalid', 'A senha n&atilde;o confere.');
    }
  }
}
